import { useNavigate, useSearchParams } from 'react-router-dom'


const Detail = ()=>{
    const navigate = useNavigate()

    // const query = useSearchParams(); // 获取到query传参
  const [ query ] = useSearchParams();
//   const [ query, setQuery ] = useSearchParams();
  //获取query传过来的参数
  const name = query.get('name')

    const goBack = ()=>{
        navigate(-1)  //this.history.go(-1)
    }

    return(<>
    <div>详情页面</div>
    <div>
        <div>收到的参数  name={name}</div>
        <button onClick={goBack}>点我返回到首页</button>
    </div>
    </>)
}

export default Detail